//
//  ViewController.swift
//  FlagApp
//
//  Created by momo on 2020/12/30.
//

import UIKit
import SnapKit
class ViewController: UIViewController {
    
    override func viewDidLoad() {
        super.viewDidLoad()
        view.backgroundColor = UIColor.white
        
        view.addSubview(view1)
        view.addSubview(view2)
        view.addSubview(view3)
        view.addSubview(touchBtn)
        view.addSubview(infoLab)
        
        view1.snp_updateConstraints { (make) in
            make.top.equalTo(100)
            make.width.equalTo(100)
            make.height.equalTo(100)
            make.centerX.equalToSuperview()
        }
        
        view2.snp_updateConstraints { (make) in
            make.top.equalTo(view1.snp_bottom).offset(20)
            make.height.equalTo(view1.snp_height)
            make.width.equalTo(100)
            make.centerX.equalTo(view1.snp_centerX)
        }

        view3.snp_updateConstraints { (make) in
            make.top.equalTo(view2.snp_bottom).offset(20)
            make.width.equalTo(view1.snp_width)
            make.height.equalTo(200)
            make.centerX.equalTo(view2.snp_centerX)
        }
        
        touchBtn.snp_updateConstraints { (make) in
            make.height.equalTo(20)
            make.bottom.equalToSuperview().offset(-30)
            make.centerX.equalToSuperview()
        }
        
        infoLab.snp_updateConstraints { (make) in
            make.left.equalToSuperview().offset(20)
            make.bottom.equalTo(touchBtn.snp_top).offset(-30)
            make.width.lessThanOrEqualTo(60)
            make.height.lessThanOrEqualTo(500)
        }
        
        
    }

    
    lazy var view1: UIView = {
        () -> UIView in
        let view = UIView()
        view.backgroundColor = UIColor.green
        
        return view
    }()

    lazy var view2: UIView = {
        () -> UIView in
        let view = UIView()
        view.backgroundColor = UIColor.red
        return view
    }()
    
    lazy var view3: UIView = {
        () -> UIView in
        let view = UIView()
        view.backgroundColor = UIColor.blue
        return view
    }()
    
    lazy var touchBtn: UIButton = {
        () -> UIButton in
        let btn = UIButton()
        btn.setTitle("点击移动", for: .normal)
        btn.setTitleColor(UIColor.red, for: .normal)
        btn.titleLabel?.font = UIFont.systemFont(ofSize: 15)
        btn.addTarget(self, action: #selector(btnTouch), for: .touchUpInside)
        return btn
    }()
    
    lazy var infoLab: UILabel = {
        () -> UILabel in
        let lab = UILabel()
        lab.text = "这是一个测试内容，这是一个测试内容，这是一个测试内容，这是一个测试内容，这是一个测试内容，这是一个测试内容，这是一个测试内容，这是一个测试内容，这是一个测试内容，"
        lab.font = UIFont.systemFont(ofSize: 16)
        lab.numberOfLines = 0
        return lab
    }()
    
    @objc func btnTouch() {
        view2.backgroundColor = UIColor.black
        
    }
}

